/**
 * 页面事件回调
 */
/**
 * 登录
 */
LOGIN = {};
LOGIN.__INIT__ = function () {
    myApp_.hideNavbar('.navbar');
    myApp_.hideToolbar(".toolbar");
    LOGIN.jump();
}
//数据
LOGIN.data = {
    telephone: null
    , password: null
}

LOGIN.jump = function () {
    mainView.router.load({
        url: 'src/index/login/login.html'
        , animatePages: false
    });
}
//手机号密码登录
LOGIN.submit = function () {
    LOGIN.data.telephone = $('#password_login input[name="username"]').val();
    LOGIN.data.password = $('#password_login input[name="password"]').val();
    request_(
        url_('index/User/login')
        , LOGIN.data
        , function (d) {
            if (d.code == 0) {
                go_href_('#/');
            } else {
                my_tips_(d.msg);
            }
        }
    );
}


//手机号自动注册登录
LOGIN.sms_login = function(){
	var name = $('#duanxin_login input[name="telephone"]').val();
    var pwd = $('#duanxin_login input[name="phone_code"]').val();
    login_phone_code_(name, pwd);
}

function login_phone_code_(name, pwd) {
    var url = url_('index/User/sms_login');
    var data = {'telephone': name, 'telephone_code': pwd};
    var success = function (d) {
        if (d.code == 0) {
            go_href_('#/');
        } else {
            my_tips_(d.msg);
        }
    }
    //跨域请求
    request_(url, data, success);
}

function login_send_phone_code() {
    send_code("#login_send_code_btn", "#duanxin_login input[name='telephone']")
}